#import <Foundation/Foundation.h>

//============== CLASS: TIRE ==================
@interface Tire : NSObject
{
    //No instance variables....
}
@end


@implementation Tire

- (NSString *) Description
{
    return (@"I am a tire. I last a while");
}

@end
//============== CLASS: TIRE ==================



//============== CLASS: ENGINE ==================
@interface Engine : NSObject
{
    //No instance variables....
}

@end


@implementation Engine

- (NSString *) Description
{
    return (@"I am an Engine. Vrooom!");
}

@end


//============== CLASS: ENGINE ==================



//============== CLASS: CAR ==================
@interface Car : NSObject
{
    //Instance variables....
    Engine *engine;
    Tire *tires[4]; //C-Style array
}

-(void) print;

@end


@implementation Car

//M001: intialization of pointers OR dynamic instance variables
- (id) init
{
    if ( self = [super init] ) 
    {
        engine = [Engine new]; //initialize engine instance variable prt
        
        for (int i=0; i< 4; i++) 
        { 
            tires[i] = [Tire new]; //initialize engine instance variable prt 
        }
    }//end-if
    
    return (self);
}


//M002: Print the Car object, with Engine and Tires
- (void) print
{
    NSLog( @ "%@", [engine Description] );
    
    for (int i=0; i< 4; i++) 
    { 
        NSLog( @"%@", [tires[i] Description] ); 
    }//for-loop
    
}

@end


//============== CLASS: CAR ==================



int main (int argc, const char * argv[]) 
{
    Car *car = [Car new];
    
    printf("\n\n================================\n");
    
    [car print];
    
    printf("================================\n\n");
    
    return (0);
}
